const Router = require('koa-router')  //注意：引入的方式

const {userValidator,verifyUser,crpytPassword, verifyLogin, verifyPass} = require('../middleware/user.moddleware')
const { auth } = require('../middleware/auth.middleware')
const { register, login, changePassword, deleteUser,search_user } = require('../controller/user.controller')
const router = new Router({ prefix: '/users' })

// 注册
router.post('/register', userValidator, verifyUser, crpytPassword, register)
// 登录
router.post('/login',userValidator, verifyLogin, login)
// 修改密码
router.post('/edit', auth, verifyPass, crpytPassword, changePassword)
// 删除用户
router.post('/delete', deleteUser)
// 查询用户
router.post('/search', auth, search_user)

module.exports = router